define(function(require, exports, module) {

    module.exports = function() {

        var refresh = null;
        var infinite = null;

        return {

            data: {
                title: "示例页面",
                items: []
            },
            methods: {

                init: function(panel, popup) {
                    var me = this;
                    //无限滚动
                    infinite = $(this.$el).infinite(function() {
                        me.load(this);
                    }, 15);
                    //下拉刷新
                    refresh = $(this.$el).refresh(function() {
                        infinite.reload();
                    });
                },
                resume: function(params) {
                    this.title = "示例标题";
                    if (params.refresh) {
                        params.refresh = false;
                        refresh.refresh();
                    }
                },
                load: function(paging) {
                    var me = this;
                    var page = paging.getPage();
                    var pageSize = paging.getPageSize();
                    if (page == 1) {
                        me.items = [];
                    }
                    console.log("读取第" + page + "页数据，每页数量：" + pageSize);
                    //模拟读取列表数据
                    setTimeout(function() {
                        //测试数据
                        var total = 200;
                        var items = [];
                        var index = (page - 1) * pageSize;
                        for (var i = 0; i < 15; i++) {
                            typeIndex = i % 3;
                            items.push({
                                name: "名称_" + index ++,
                                type: typeIndex
                            });
                        }
                        //添加数据到vue
                        paging.push(me.items, items, total);
                        //结束读取，如果不使用paging.push方法，执行paging.finish();
                        //paging.finish();
                        refresh.finish();
                    }, 1000);

                },
                addNotification:function(item) {
                    $.app.addNotification({
                        title:item.name,
                        message:item.name + "_通知内容"
                    });
                },
                destroy: function() {
                    console.log("onDestroy*******");
                },
                onButtonBack:function() {
                    return true;
                }

            }
        }
    }

});